package com.advanced.homeworkCompany;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Company {

	String companyName;
	String companyAddress;
	String companyPhone;
	String companyBusiness;
	ArrayList<Employee> employee = new ArrayList<Employee>();

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public String getCompanyAddress() {
		return companyAddress;
	}

	public void setCompanyAddress(String companyAddress) {
		this.companyAddress = companyAddress;
	}

	public String getCompanyPhone() {
		return companyPhone;
	}

	public void setCompanyPhone(String companyPhone) {
		this.companyPhone = companyPhone;
	}

	public String getCompanyBusiness() {
		return companyBusiness;
	}

	public void setCompanyBusiness(String companyBusiness) {
		this.companyBusiness = companyBusiness;
	}

	public boolean findEmployee(int id) {// 寻找员工
		for (int i = 0; i < employee.size(); i++) {
			if (employee.get(i).getId() == id) {
				return true;
			}
		}
		return false;
	}

	public void offer(String employeeName, int age, String gender, String position, double salary, int id) {// 招聘员工
		if (findEmployee(id)) {
			System.out.println("员工工号不能重复!");
			return;
		}
		employee.add(new Employee(employeeName, age, gender, position, salary, id));
		System.out.println("添加成功!");
		return;
	}

	public void showInfor() {// 显示员工信息
		System.out.println("员工信息：");
		System.out.println("序号\t姓名\t年龄\t性别\t职务\t薪水\t工号");
		for (int i = 0; i < employee.size(); i++) {
			if (employee.get(i) != null) {
				System.out.print((i + 1) + "、   ");
				employee.get(i).show();
			}
		}
	}

	public void employeeNum() {// 统计公司人数
		System.out.println("统计公司人数");
		System.out.println("公司人数共有" + employee.size() + "人");

	}

	public void fire(int num) {// 开除员工
		if (findEmployee(num)) {
			for (int i = 0; i < employee.size(); i++) {
				if (employee.get(i).getId() == num) {
					employee.remove(i);
					System.out.println("工号：" + num + "删除成功！");
				}
			}
		} else {
			System.out.println("未找到该工号员工！");
		}
	}

	public Company() {

	}

	public Company(String companyName, String companyAddress, String companyPhone, String companyBusiness) {
		setCompanyName(companyName);
		setCompanyAddress(companyAddress);
		setCompanyPhone(companyPhone);
		setCompanyBusiness(companyBusiness);
	}

}
